<?php
namespace Admin\Controller;
use Admin\Controller\BaseController;

class CommentsController extends BaseController{
	private $M;
	public function _initialize()
	{
		$this->M = M("orders_comments");
	}
	/*
    *   分页显示
    */
    public function index(){
    	$orders_commentsInfo = M('orders_comments')->limit(0,10)->select();
		$this->assign('orders_commentsInfo',$orders_commentsInfo);
        $count = $this->M->count();    // 总记录数
        $pages = ceil($count / $this->perpage);
        $nowpage = I("p");
        if(empty($nowpage)){
            $nowpage = 1;
        }
        $Page = new \Think\Page($count, $this->perpage);
        $Page->setConfig("prev", "上一页");
        $Page->setConfig("next", "下一页");
        $list = $this->M->limit($Page->firstRow.','.$Page->listRows)->select();   // 每页的数据数组
        $show = $Page->show();  // 页码链接内容
        $this->assign("count", $count);
        $this->assign("list", $list);
        $this->assign("page", $show);
        $this->assign("pages", $pages);
        $this->assign("nowpage", $nowpage);
        $this->display();
    }
    //上传商品评论
	
 
    //删除方法
    public function del(){
        $id = I("id");

        if($id){
            $res = $this->M->where("orders_id=".$id)->delete();
        }
        if($res){
            $this->success("操作成功", U("Comments/index"));
        }
        else{
            $this->error("操作失败", U("Comments/index"));
        }
    }

}